﻿using System;
using System.Collections.Generic;

using E.BLL;
using E.Model;
using E.Web.UI.Page;

using X.Pager;
using X.Pager.List;
using X.Common;

namespace E.Web.Teacher.interactive
{
    public partial class List : TeacherBasePage
    {
        public IList<ShortQandAModel> qandaList;
        public string act;
        public string userName;
        public string fromDate;
        public string toDate;
        public int isReply;

        protected override void ShowPage()
        {
            InitSearchDateTime();
            act = XRequest.GetString("act");
            userName = XRequest.GetString("UserNameTxt");
            isReply = XRequest.GetInt("IsReplySlt", -1);

            if (ispost || act == "s")
            {
                TeacherBLL bll = new TeacherBLL();
                SearchQandAListModel model = new SearchQandAListModel();
                model.UserID = -1;
                model.UserName = userName;
                model.TeacherID = teacherid;
                model.TeacherName = "";
                model.FromDate = fromDate;
                model.ToDate = toDate;
                model.IsReply = isReply;
                model.IsNew = -1;

                QandAListModel listModel = new QandAListModel();

                CheckPageIndexValue(XRequest.GetInt("s", 1) - 1, XRequest.GetInt("g", 0), XRequest.GetInt("z", customerPageSize));

                listModel = bll.GetQandAListByCondition(model, customerPageSize, pageIndex);
                if (listModel.TotalCount > 0)
                {
                    count = listModel.TotalCount;
                    qandaList = listModel.List;
                    PagerBase pager = new ListPager(count, pageIndex, currentPgGroup, customerPageSize, defaultPagesInGroup);

                    Dictionary<string, string> parms = new Dictionary<string, string>();
                    parms.Add("act", act);
                    parms.Add("UserNameTxt", userName);
                    parms.Add("FromDateTxt", fromDate);
                    parms.Add("ToDateTxt", toDate);
                    parms.Add("IsReplySlt", isReply.ToString());
                    mypager = pager.DrawPager("selfpager", parms);
                }
            }
        }

        private void InitSearchDateTime()
        {
            try
            {
                if (!XRequest.GetString("FromDateTxt").Equals(""))
                {
                    Convert.ToDateTime(XRequest.GetString("FromDateTxt"));
                    fromDate = XRequest.GetString("FromDateTxt");
                }

                if (!XRequest.GetString("ToDateTxt").Equals(""))
                {
                    Convert.ToDateTime(XRequest.GetString("ToDateTxt"));
                    toDate = XRequest.GetString("ToDateTxt");
                }
            }
            catch (Exception ex)
            {

            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}
